package tsb.trinhnx;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author TrinhNX
 *
 */
public class Test1 {
	public static void main(String[] args) {
		Test1 test = new Test1();
		test.bai1();
	}

	private void bai1() {
		final int[] inputA = { 203, 204, 205, 206, 207, 203, 204, 205, 206 };
		final int[] inputB = { 203, 204, 204, 205, 206, 207, 205, 208, 203, 206, 205, 206, 204 };
		// Sort
		Arrays.sort(inputA);
		Arrays.sort(inputB);
		// Move to array list
		ArrayList<Integer> listA = new ArrayList<Integer>(inputA.length);
		for (int i = 0; i < inputA.length; i++) {
			listA.add(inputA[i]);
		}
		ArrayList<Integer> listB = new ArrayList<Integer>(inputB.length);
		for (int i = 0; i < inputB.length; i++) {
			listB.add(inputB[i]);
		}
		// OK, our job
		int M = listA.size();
		int N = listB.size();
		int tempIndex = 0;
		// We will loop until end of the list
		/**
		 * Idea: Will use the mark value to mark the missing index
		 */
		while (tempIndex < M || tempIndex < N) {
			// Index out of bound exception, we will add the mark value
			if (tempIndex >= M) {
				listA.add(tempIndex, -1);
			}
			if (tempIndex >= N) {
				listB.add(tempIndex, -1);
			}
			// Get current value
			int tempA = listA.get(tempIndex);
			int tempB = listB.get(tempIndex);
			// If this is mark, ignore
			if (tempA == -1 || tempB == -1) {
				System.out.println("Get it" + tempIndex);
			} else {
				// If A is smaller, it is missing from B
				// Else If B is smaller, it is missing from A
				if (tempA < tempB) {
					listB.add(tempIndex, -1);
				} else if (tempA > tempB) {
					listA.add(tempIndex, -1);
				}
			}
			// Increasing the index.
			tempIndex = tempIndex + 1;
			// Update the size
			M = listA.size();
			N = listB.size();
		}
		// They have the same size
		for (int i = 0; i < listA.size(); i++) {
			// Check the mark value
			if (listA.get(i) == -1) {
				System.out.println(listB.get(i));
			}
			if (listB.get(i) == -1) {
				System.out.println(listA.get(i));
			}
		}

	}
}
